import {defineStore, StateTree, StoreDefinition} from "pinia";
import {authMailService} from "@/service/auth";
import {Response} from "@/entity/net";

export const MailStore: StoreDefinition = defineStore("mailStore", {
    state: () => {
        return {
            email: "",
            ecode: ""
        };
    },
    actions: {
        sendAuthMail(): Response<boolean> {
            return authMailService(this.email);
        },
        reset(): void {
            this.reset();
        }
    },
    getters: {
        getAuthCode: (state: StateTree) => state.ecode
    }
});